package com.apes.fn.server.productRequire.impl;


import com.apes.fn.server.productRequire.requireDataBuild.AppMaterialChangeRequire;
import com.apes.fn.server.productRequire.requireDataBuild.LossQuotationChangeRequire;
import com.apes.fn.server.productRequire.ProductRequire;
import com.apes.fn.server.productRequire.requireDataBuild.ServicePlanChangeRequire;
import com.apes.framework.api.DomainService;
import com.apes.framework.plugin.esb.api.SimpleRequest;

import java.util.List;

public abstract class AbstractProductRequireDataConversion extends DomainService implements ProductRequireDataConversionImp{


    @Override
    public List<ProductRequire> externalDataChangeRequireData(SimpleRequest request) {
        return null;
    }

    public static ProductRequireDataConversionImp init(String businessType) {
        try {
            if (businessType.equals(LossQuotationChangeRequire.class.getDeclaredField("BUSINESS_TYPE").get("BUSINESS_TYPE"))) {
                return getBean(LossQuotationChangeRequire.class);
            } else if (businessType.equals(ServicePlanChangeRequire.class.getDeclaredField("BUSINESS_TYPE").get("BUSINESS_TYPE"))) {
                return getBean(ServicePlanChangeRequire.class);
            } else if (businessType.equals(AppMaterialChangeRequire.class.getDeclaredField("BUSINESS_TYPE").get("BUSINESS_TYPE"))) {
                return getBean(AppMaterialChangeRequire.class);
            }
        } catch (Exception e) {
            throw new RuntimeException("未匹配到单据类型！");
        }
        return null;
    }
}
